import axios from 'axios'
// import { Message } from 'element-ui'

const request = axios.create({
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000
})

request.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

request.interceptors.response.use(
  response => {
    // if (response.data.code === 0 && response.data.msg === 'success') {
    //   return response.data
    // } else {
    //   Message({
    //     type: 'error',
    //     message: response.data.msg
    //   })
    //   return Promise.reject(response.data)
    // }
    return response.data
  },
  error => {
    return Promise.reject(error)
  }
)

export default request
